//
//  PersonView.m
//  兼职页面
//
//  Created by kuiyuan liang on 2021/5/25.
//

#import "PersonView.h"
#import "CommonUtil.h"

@interface PersonView()


@property (strong, nonatomic) UILabel * timeLabel;
@property (strong, nonatomic) UILabel * levelLabel;

@end

@implementation PersonView


-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.iconImageView];
        [self addSubview:self.nameLabel];
        [self addSubview:self.timeLabel];
        [self addSubview:self.levelLabel];
        
        self.nameLabel.text = @"今非昔比";
        self.timeLabel.text = @"2021-05-03 01:19";
        self.levelLabel.text = @"LV1";
        
        [self.nameLabel sizeToFit];
        self.levelLabel.left = self.nameLabel.right+AD(3);
        
    }
    return self;
}

#pragma mark - lazy
-(UIImageView *)iconImageView{
    if (!_iconImageView) {
        _iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(AD(20),0 , AD(40), AD(40))];
        _iconImageView.image = [UIImage imageNamed:@"defaultIcon.jpeg"];
        _iconImageView.layer.cornerRadius = AD(20);
        _iconImageView.clipsToBounds = YES;
    }
    return _iconImageView;
}

-(UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(_iconImageView.right + AD(10), 0, AD(100), AD(25))];
        _nameLabel.font = [UIFont systemFontOfSize:AD(18)];
        _nameLabel.textColor = [UIColor blackColor];
    }
    return _nameLabel;
}

-(UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(_nameLabel.left, _nameLabel.bottom, AD(200), AD(15))];
        _timeLabel.font = [UIFont systemFontOfSize:AD(12)];
        _timeLabel.textColor = [UIColor lightGrayColor];
    }
    return _timeLabel;
}

-(UILabel *)levelLabel{
    if (!_levelLabel) {
        _levelLabel = [[UILabel alloc] initWithFrame:CGRectMake(_nameLabel.right, AD(5), AD(20), AD(15))];
        _levelLabel.font = [UIFont systemFontOfSize:AD(10)];
        _levelLabel.textColor = [UIColor whiteColor];
        _levelLabel.backgroundColor = RGB(156.0, 168.0, 168.0);
        _levelLabel.layer.cornerRadius = AD(2);
        _levelLabel.clipsToBounds = YES;
        _levelLabel.textAlignment = NSTextAlignmentCenter;
        _levelLabel.centerY = _nameLabel.centerY;
    }
    return _levelLabel;
}


@end



